package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IProductService;
import com.mall.shopping.ITestProductService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.RecommendResponse;
import com.mall.user.annotation.Anoymous;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 商品模块   查询推荐商品
 * @author: Aaron
 * @create: 2021-06-18 11:50
 **/
@Slf4j
@RestController
@RequestMapping("/shopping")
public class RecommendController {

    @Reference(timeout = 3000, retries = 0, check = false)
    IProductService iProductService;

    //Aaron
    @GetMapping("/recommend")
    @Anoymous
    public ResponseData recommendItems() {
        RecommendResponse response = iProductService.getRecommendGoods();
        if (response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())) {
            return new ResponseUtil<>().setData(response.getPanelContentItemDtos());
        }
        return new ResponseUtil<>().setErrorMsg(response.getMsg());
    }

}
